import Vue from 'vue'
import VueI18n from 'vue-i18n'

import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang

import { enLocale } from './en-US/index'
import { zhLocale } from './zh-CN/index'

import zhCommon from './common/zh'
import enCommon from './common/en'

const env = process.env.VUE_APP_ROUTER

console.log('VueI18n---:',env)
console.log(enLocale())
console.log(zhLocale().default)
console.log('enCommon----:',enCommon)

Vue.use(VueI18n)

const messages = {
  en: {
    ...enCommon,
    ...enLocale().default,
    ...elementEnLocale
  },
  zh: {
    ...zhCommon,
    ...zhLocale().default,
    ...elementZhLocale
  }
}
let locale = process.env.VUE_APP_LANG
const i18n = new VueI18n({
  // set locale
  // options: en | zh 
  locale: locale || 'zh',
  // set locale messages
  messages
})

export default i18n